import React from 'react'
import {
  Route,
  Link,
  Switch,
  Redirect,
  NavLink,
  withRouter,
} from 'react-router-dom'
import Home from './components/Home'
import Detail from './components/Detail'

function App(props) {
  console.log(props)
  return (
    <div>
      App
      <button
        onClick={() => {
          props.history.push('/detail', '哈哈') // push是往历史记录里面加一条
          // props.history.replace('/detail?name=ls&age=20', '嘻嘻') // replace是替换历史记录
        }}
      >
        切换视图
      </button>
      <hr />
      <Link to="/home">home</Link>
      <Link to="/detail">detail</Link>
      <hr />
      <Route path="/" component={Home} exact></Route>
      <Route path="/home" component={Home}></Route>
      <Route path="/detail/:id?" component={Detail}></Route>
      <hr />
    </div>
  )
}
const WithApp = withRouter(App)
export default WithApp
